﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using LunarPhase.Gadget.ViewModel;
using LunarPhase.Model;

namespace LunarPhase.Test
{
    
    
    /// <summary>
    ///This is a test class for PhaseCalculatorTest and is intended
    ///to contain all PhaseCalculatorTest Unit Tests
    ///</summary>
    [TestClass()]
    public class PhaseCalculatorTest
    {

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for PhaseCalculator Constructor
        ///</summary>
        [TestMethod()]
        public void PhaseCalculatorConstructorTest()
        {
            PhaseCalculator target = new PhaseCalculator();
            Assert.IsNotNull(target);
        }

        /// <summary>
        ///A test for Calculate
        ///</summary>
        [TestMethod()]
        public void OctoberFour2009WasFullMoon()
        {
            PhaseCalculator target = new PhaseCalculator(); 
            DateTime date = new DateTime(2009,10,4);
            PhaseCalculatorResult expected = new PhaseCalculatorResult() { Phase = Model.LunarPhase.FULL }; 
            PhaseCalculatorResult actual;
            actual = target.Calculate(date);
            Assert.AreEqual(expected.Phase, actual.Phase);
        }

        [TestMethod()]
        public void February282010WasFullMoon()
        {
            PhaseCalculator target = new PhaseCalculator();
            DateTime date = new DateTime(2010, 2, 28);
            PhaseCalculatorResult expected = new PhaseCalculatorResult() { Phase = Model.LunarPhase.FULL };
            PhaseCalculatorResult actual;
            actual = target.Calculate(date);
            Assert.AreEqual(expected.Phase, actual.Phase);
        }

        [TestMethod()]
        public void October311982WasFullMoon()
        {
            PhaseCalculator target = new PhaseCalculator();
            DateTime date = new DateTime(1982, 10, 31);
            PhaseCalculatorResult expected = new PhaseCalculatorResult() { Phase = Model.LunarPhase.FULL };
            PhaseCalculatorResult actual;
            actual = target.Calculate(date);
            Assert.AreEqual(expected.Phase, actual.Phase);
        }

        [TestMethod()]
        public void June241990WasNewMoon()
        {
            PhaseCalculator target = new PhaseCalculator();
            DateTime date = new DateTime(1990, 6, 24);
            Model.LunarPhase expected = Model.LunarPhase.NEW;
            PhaseCalculatorResult actual;
            actual = target.Calculate(date);
            Assert.AreEqual(expected, actual.Phase);
        }


        [TestMethod()]
        public void December132001()
        {
            PhaseCalculator target = new PhaseCalculator();
            DateTime date = new DateTime(2001, 12, 13);
            Model.LunarPhase expected = Model.LunarPhase.NEW;
            PhaseCalculatorResult actual;
            actual = target.Calculate(date);
            Assert.AreEqual(expected, actual.Phase);
        }

        [TestMethod()]
        public void June101980WasWaningCrescent()
        {
            PhaseCalculator target = new PhaseCalculator();
            DateTime date = new DateTime(1980, 6, 10);
            Model.LunarPhase expected = Model.LunarPhase.WaningCrescent;
            PhaseCalculatorResult actual;
            actual = target.Calculate(date);
            Assert.AreEqual(expected, actual.Phase);
        }

        [TestMethod()]
        public void January82010WasLastQuarter()
        {
            PhaseCalculator target = new PhaseCalculator();
            DateTime date = new DateTime(2010, 1, 8);
            Model.LunarPhase expected = Model.LunarPhase.LastQuarter;
            PhaseCalculatorResult actual;
            actual = target.Calculate(date);
            Assert.AreEqual(expected, actual.Phase);
        }
        [TestMethod()]
        public void June211980WasFirstQuarter()
        {
            PhaseCalculator target = new PhaseCalculator();
            DateTime date = new DateTime(1980, 6, 21);
            Model.LunarPhase expected = Model.LunarPhase.FirstQuarter;
            PhaseCalculatorResult actual;
            actual = target.Calculate(date);
            Assert.AreEqual(expected, actual.Phase);
        }


        [TestMethod()]
        public void February282010WasFirstQuarter()
        {
            PhaseCalculator target = new PhaseCalculator();
            DateTime date = new DateTime(2010, 2, 28);
            Model.LunarPhase expected = Model.LunarPhase.FULL;
            PhaseCalculatorResult actual;
            actual = target.Calculate(date);
            Assert.AreEqual(expected, actual.Phase);
        }

        /// <summary>
        ///A test for moon_posit
        ///</summary>
        [TestMethod()]
        [DeploymentItem("FaseLunar.dll")]
        public void MoonPositionTest()
        {
            PhaseCalculator_Accessor target = new PhaseCalculator_Accessor(); 
            int Y = 1982; 
            int M = 10; 
            int D = 31;
            Model.LunarPhase expected = Model.LunarPhase.FULL;
            PhaseCalculatorResult actual;
            actual = target.MoonPosition(Y, M, D);
            Assert.AreEqual(expected, actual.Phase);
        }

        /// <summary>
        ///A test for normalize
        ///</summary>
        [TestMethod()]
        [DeploymentItem("FaseLunar.dll")]
        public void NormalizeNegativeTest()
        {
            PhaseCalculator_Accessor target = new PhaseCalculator_Accessor(); 
            double v = -0.5; 
            double expected = 0.5; 
            double actual;
            actual = target.Normalize(v);
            Assert.AreEqual(expected, actual);
        }


        
        /// <summary>
        ///A test for round2
        ///</summary>
        [TestMethod()]
        [DeploymentItem("FaseLunar.dll")]
        public void Round2Test()
        {
            PhaseCalculator_Accessor target = new PhaseCalculator_Accessor(); 
            double x = 0.55123;
            double expected = 0.55;
            double actual;
            actual = target.Round2(x);
            Assert.AreEqual(expected, actual);
        }

        #region Determiknating Zodiac

        [TestMethod()]
        [DeploymentItem("FaseLunar.dll")]
        public void DeterminateZodiacPisces()
        {
            PhaseCalculator_Accessor target = new PhaseCalculator_Accessor();
            double LO = 30;
            Zodiac expected = Zodiac.Pisces;
            Zodiac actual;
            actual = target.DeterminateZodiac(LO);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        [DeploymentItem("FaseLunar.dll")]
        public void DeterminateZodiacAries()
        {
            PhaseCalculator_Accessor target = new PhaseCalculator_Accessor();
            double LO = 50;
            Zodiac expected = Zodiac.Aries;
            Zodiac actual;
            actual = target.DeterminateZodiac(LO);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        [DeploymentItem("FaseLunar.dll")]
        public void DeterminateZodiacTaurus()
        {
            PhaseCalculator_Accessor target = new PhaseCalculator_Accessor();
            double LO = 90;
            Zodiac expected = Zodiac.Taurus;
            Zodiac actual;
            actual = target.DeterminateZodiac(LO);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        [DeploymentItem("FaseLunar.dll")]
        public void DeterminateZodiacGemini()
        {
            PhaseCalculator_Accessor target = new PhaseCalculator_Accessor();
            double LO = 119;
            Zodiac expected = Zodiac.Gemini;
            Zodiac actual;
            actual = target.DeterminateZodiac(LO);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        [DeploymentItem("FaseLunar.dll")]
        public void DeterminateZodiacCancer()
        {
            PhaseCalculator_Accessor target = new PhaseCalculator_Accessor();
            double LO = 130;
            Zodiac expected = Zodiac.Cancer;
            Zodiac actual;
            actual = target.DeterminateZodiac(LO);
            Assert.AreEqual(expected, actual);
        }


        [TestMethod()]
        [DeploymentItem("FaseLunar.dll")]
        public void DeterminateZodiacLeo()
        {
            PhaseCalculator_Accessor target = new PhaseCalculator_Accessor();
            double LO = 170;
            Zodiac expected = Zodiac.Leo;
            Zodiac actual;
            actual = target.DeterminateZodiac(LO);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        [DeploymentItem("FaseLunar.dll")]
        public void DeterminateZodiacVirgo()
        {
            PhaseCalculator_Accessor target = new PhaseCalculator_Accessor();
            double LO = 220;
            Zodiac expected = Zodiac.Virgo;
            Zodiac actual;
            actual = target.DeterminateZodiac(LO);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        [DeploymentItem("FaseLunar.dll")]
        public void DeterminateZodiacLibra()
        {
            PhaseCalculator_Accessor target = new PhaseCalculator_Accessor();
            double LO = 240;
            Zodiac expected = Zodiac.Libra;
            Zodiac actual;
            actual = target.DeterminateZodiac(LO);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        [DeploymentItem("FaseLunar.dll")]
        public void DeterminateZodiacScorpio()
        {
            PhaseCalculator_Accessor target = new PhaseCalculator_Accessor();
            double LO = 270;
            Zodiac expected = Zodiac.Scorpio;
            Zodiac actual;
            actual = target.DeterminateZodiac(LO);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        [DeploymentItem("FaseLunar.dll")]
        public void DeterminateZodiacSagittarius()
        {
            PhaseCalculator_Accessor target = new PhaseCalculator_Accessor();
            double LO = 300;
            Zodiac expected = Zodiac.Sagittarius;
            Zodiac actual;
            actual = target.DeterminateZodiac(LO);
            Assert.AreEqual(expected, actual);
        }


        [TestMethod()]
        [DeploymentItem("FaseLunar.dll")]
        public void DeterminateZodiacCapricorn()
        {
            PhaseCalculator_Accessor target = new PhaseCalculator_Accessor();
            double LO = 310;
            Zodiac expected = Zodiac.Capricorn;
            Zodiac actual;
            actual = target.DeterminateZodiac(LO);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        [DeploymentItem("FaseLunar.dll")]
        public void DeterminateZodiacAquarius()
        {
            PhaseCalculator_Accessor target = new PhaseCalculator_Accessor();
            double LO = 340;
            Zodiac expected = Zodiac.Aquarius;
            Zodiac actual;
            actual = target.DeterminateZodiac(LO);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        [DeploymentItem("FaseLunar.dll")]
        public void DeterminateBizarreZodiacMustBePisces()
        {
            PhaseCalculator_Accessor target = new PhaseCalculator_Accessor();
            double LO = 370;
            Zodiac expected = Zodiac.Pisces;
            Zodiac actual;
            actual = target.DeterminateZodiac(LO);
            Assert.AreEqual(expected, actual);
        }

#endregion

        #region Determinating Lunar Phase

        [TestMethod()]
        [DeploymentItem("FaseLunar.dll")]
        public void DeterminateNEWPhase()
        {
            PhaseCalculator_Accessor target = new PhaseCalculator_Accessor();
            double moonAge = 1.84565;
            Model.LunarPhase expected = Model.LunarPhase.NEW;
            Model.LunarPhase actual = target.DeterminatePhase(moonAge);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        [DeploymentItem("FaseLunar.dll")]
        public void DeterminateWaxingCrescentPhase()
        {
            PhaseCalculator_Accessor target = new PhaseCalculator_Accessor();
            double moonAge = 5.53698;
            Model.LunarPhase expected = Model.LunarPhase.WaxingCrescent;
            Model.LunarPhase actual = target.DeterminatePhase(moonAge);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        [DeploymentItem("FaseLunar.dll")]
        public void DeterminateFirstQuarterPhase()
        {
            PhaseCalculator_Accessor target = new PhaseCalculator_Accessor();
            double moonAge = 9.22830;
            Model.LunarPhase expected = Model.LunarPhase.FirstQuarter;
            Model.LunarPhase actual = target.DeterminatePhase(moonAge);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        [DeploymentItem("FaseLunar.dll")]
        public void DeterminateWaxingGibbousPhase()
        {
            PhaseCalculator_Accessor target = new PhaseCalculator_Accessor();
            double moonAge = 12.91962;
            Model.LunarPhase expected = Model.LunarPhase.WaxingGibbous;
            Model.LunarPhase actual = target.DeterminatePhase(moonAge);
            Assert.AreEqual(expected, actual);
        }
        
        [TestMethod()]
        [DeploymentItem("FaseLunar.dll")]
        public void DeterminateFULLPhase()
        {
            PhaseCalculator_Accessor target = new PhaseCalculator_Accessor();
            double moonAge = 16.61095;
            Model.LunarPhase expected = Model.LunarPhase.FULL;
            Model.LunarPhase actual = target.DeterminatePhase(moonAge);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        [DeploymentItem("FaseLunar.dll")]
        public void DeterminateWaningGibbousPhase()
        {
            PhaseCalculator_Accessor target = new PhaseCalculator_Accessor();
            double moonAge = 20.30227;
            Model.LunarPhase expected = Model.LunarPhase.WaningGibbous;
            Model.LunarPhase actual = target.DeterminatePhase(moonAge);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        [DeploymentItem("FaseLunar.dll")]
        public void DeterminateLastQuarterPhase()
        {
            PhaseCalculator_Accessor target = new PhaseCalculator_Accessor();
            double moonAge = 23.99360;
            Model.LunarPhase expected = Model.LunarPhase.LastQuarter;
            Model.LunarPhase actual = target.DeterminatePhase(moonAge);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        [DeploymentItem("FaseLunar.dll")]
        public void DeterminateWaningCrescentPhase()
        {
            PhaseCalculator_Accessor target = new PhaseCalculator_Accessor();
            double moonAge = 27.68492;
            Model.LunarPhase expected = Model.LunarPhase.WaningCrescent;
            Model.LunarPhase actual = target.DeterminatePhase(moonAge);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        [DeploymentItem("FaseLunar.dll")]
        public void DeterminateExceptionalNEWPhase()
        {
            PhaseCalculator_Accessor target = new PhaseCalculator_Accessor();
            double moonAge = 27.68493;
            Model.LunarPhase expected = Model.LunarPhase.NEW;
            Model.LunarPhase actual = target.DeterminatePhase(moonAge);
            Assert.AreEqual(expected, actual);
        }
        #endregion


        
    }
}
